﻿using System;
using System.Runtime.Remoting.Messaging;
using LitJson;

namespace OestsCommon.TcpNet
{
    /// <summary>
    /// 包
    /// </summary>
    public class Response:Packet
	{
        public PacketKey ResponseCode = PacketKey.None;

        public SubCode ResponseSubCode = SubCode.None;

		/// <summary>
		/// 返回操作结果 成功 失败 错误等
		/// </summary>
		public ReturnCode ReturnCode = ReturnCode.None;

		/// <summary>
		/// 返回操作信息描述 失败的原因
		/// </summary>
		public string RetrunMessage = "";

		public Response()
        {
            
        }
        public Response(PacketKey key)
        {
            ResponseCode = key;
        }

        /// <summary>
        ///将请求变为响应，并且返回代码为 Success
        /// </summary>
        /// <param name="r"></param>
        public Response(Request r)
        {
            ResponseCode = r.RequestCode;
            ResponseSubCode = r.RequestSubCode;
            ReturnCode = ReturnCode.Success;
            DataObject = r.DataObject;
        }
        public Response(PacketKey key, SubCode subCode)
        {
			ResponseCode = key;
            ResponseSubCode = subCode;
        }

    
        public Response(PacketKey key, SubCode subCode, ReturnCode returnCode,  string returnMsg,object ObjParameter=null)
        {
			ResponseCode = key;
			ResponseSubCode = subCode;
            ReturnCode = returnCode;
            RetrunMessage = returnMsg;
            DataObject = ObjParameter;
        }
      
    }

}